
_realname=suil
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.10.18
pkgrel=1
pkgdesc="A lightweight C library for loading and wrapping LV2 plugin UIs (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://drobilla.net/software/suil.html"
license=("spdx:ISC")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-gtk2"
  "${MINGW_PACKAGE_PREFIX}-gtk3"
  "${MINGW_PACKAGE_PREFIX}-lv2"
  "${MINGW_PACKAGE_PREFIX}-meson"
  "${MINGW_PACKAGE_PREFIX}-pkgconf"
  "${MINGW_PACKAGE_PREFIX}-qt5-base" 
)
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
optdepends=(
  "${MINGW_PACKAGE_PREFIX}-glib2: Support for wrapping Qt5 in GTK3 and GTK2"
  "${MINGW_PACKAGE_PREFIX}-gtk2: Support for wrapping Qt5 in GTK2 and GTK2 in Qt5"
  "${MINGW_PACKAGE_PREFIX}-gtk3: Support for wrapping Qt5 in GTK3"
  "${MINGW_PACKAGE_PREFIX}-qt5-base: support for wrapping Qt5 in GTK3 and GTK2"
)
source=("https://download.drobilla.net/${_realname}-${pkgver}.tar.xz"
        001-undefined-using.patch)
sha256sums=('84ada094fbe17ad3e765379002f3a0c7149b43b020235e4d7fa41432f206f85f'
            '39c9465e29e82f5345edce62d5f0263382ceac0e115e640d8fac7d2864f04fe4')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"

  # Workaround for https://gitlab.com/lv2/suil/-/issues/8
  patch -Np1 -i "${srcdir}/001-undefined-using.patch"
}

build() {
  [[ -d "build-${MSYSTEM}" ]] && rm -rf "build-${MSYSTEM}"
  mkdir -p "${srcdir}/build-${MSYSTEM}"
  cd "${srcdir}/build-${MSYSTEM}"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe \
    --buildtype=plain \
    --auto-features=enabled \
    --prefix=${MINGW_PREFIX} \
    -Dcocoa=disabled \
    -Dx11=disabled \
    -Ddocs=disabled \
    ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/meson.exe install --destdir="${pkgdir}"

  install -vDm 644 ${srcdir}/${_realname}-${pkgver}/COPYING -t "${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname/"
  install -vDm 644 ${srcdir}/${_realname}-${pkgver}/{AUTHORS,NEWS,README.md} -t "${pkgdir}${MINGW_PREFIX}/share/doc/$_realname/"
}